package com.mao.model.voucher;
/**
 * 单据类型
 */
public enum VoucherType {
	delivery, warehouse, returndelivery, returnwarehouse;

	public String getCaption() {
		if (this == delivery) {
			return "销售出库单";
		} else if (this == warehouse) {
			return "进货入库单";
		} else if (this == returndelivery) {
			return "销售退货单";
		} else if (this == returnwarehouse) {
			return "进货退货单";
		} else {
			return "未知";
		}
	}
	
	public String getVoucherClassName(){	
		Class voucherClass = getVoucherClass();
		if (voucherClass!=null){
			return voucherClass.getSimpleName();
		}else{
			return VoucherBase.class.getSimpleName();
		}
	}
	
	public  Class getVoucherClass(){		
		if (this.equals(VoucherType.delivery)){
			return DeliveryVoucher.class;
		}else if (this.equals(VoucherType.warehouse)){
			return WareHouseVoucher.class;
		}else if (this.equals(VoucherType.returndelivery)){
			return ReturnDeliveryVoucher.class;
		}else if (this.equals(VoucherType.returnwarehouse)){
			return ReturnWareHouseVoucher.class;
		}
		return null;
	}
	
	// 中间表
	public String getProductVoucherClassName(){	
		Class productVoucherClass = getProductVoucherClass();
		if (productVoucherClass!=null){
			return productVoucherClass.getSimpleName();
		}else{
			return ProductVoucherBase.class.getSimpleName();
		}
	}
	
	public  Class getProductVoucherClass(){		
		if (this.equals(VoucherType.delivery)){
			return ProductDeliveryVoucher.class;
		}else if (this.equals(VoucherType.warehouse)){
			return ProductWareHouseVoucher.class;
		}else if (this.equals(VoucherType.returndelivery)){
			return ProductReturnDeliveryVoucher.class;
		}else if (this.equals(VoucherType.returnwarehouse)){
			return ProductReturnWareHouseVoucher.class;
		}
		return null;
	}
	
	/**
	 * 进货销售中间表所对应的退货单中间表 
	 * @return
	 * @return String
	 */
	public String getReturnProductVoucherClass(){
		if (this.equals(VoucherType.delivery)){
			return ProductReturnDeliveryVoucher.class.getSimpleName();
		}else if (this.equals(VoucherType.warehouse)){
			return ProductReturnWareHouseVoucher.class.getSimpleName();
		}
		return null;
	}
	
	/**
	 * 进货销售单所对应的退货单 
	 * @return
	 * @return String
	 */
	public String getReturnVoucherClass(){
		if (this.equals(VoucherType.delivery)){
			return ReturnDeliveryVoucher.class.getSimpleName();
		}else if (this.equals(VoucherType.warehouse)){
			return ReturnWareHouseVoucher.class.getSimpleName();
		}
		return null;
	}
}
